package main

import "fmt"

type Books struct {
	title string
	author string
	subject string
	bookId int
}

func printBook(book Books) {
	fmt.Printf( "Book title : %s\n", book.title)
	fmt.Printf( "Book author : %s\n", book.author)
	fmt.Printf( "Book subject : %s\n", book.subject)
	fmt.Printf( "Book book_id : %d\n", book.bookId)
}

func printBook2(book *Books) {
	fmt.Printf( "Book title : %s\n", book.title)
	fmt.Printf( "Book author : %s\n", book.author)
	fmt.Printf( "Book subject : %s\n", book.subject)
	fmt.Printf( "Book book_id : %d\n", book.bookId)
}

func main() {
	/*// 创建一个新的结构体
	fmt.Println(Books{
		"Go语言",
		"www.runoob.com",
		"Go语言教程",
		123456,
	})
	// 也可以使用key->value格式
	fmt.Println(Books{
		title: "Go语言",
		author: "www.runoob.com",
		subject: "Go语言教程",
		bookId: 123456,
	})
	// 忽略的字段为0或空
	fmt.Println(Books{
		title: "Go语言",
		author: "www.runoob.com",
	})*/

	/*var Book1 Books
	var Book2 Books
	// Book1描述
	Book1.title = "Go语言"
	Book1.author = "www.runoob.com"
	Book1.subject = "Go语言教程"
	Book1.bookId = 123456
	// Book2描述
	Book2.title = "Python语言"
	Book2.author = "www.runoob.com"
	Book2.subject = "Python语言教程"
	Book2.bookId = 654321
	// 打印Book1信息
	fmt.Printf("Book 1 title:%s\n", Book1.title)
	fmt.Printf("Book 1 author:%s\n", Book1.author)
	fmt.Printf("Book 1 subject:%s\n", Book1.subject)
	fmt.Printf("Book 1 bookId:%d\n", Book1.bookId)
	// 打印Book2信息
	fmt.Printf("Book 2 title:%s\n", Book2.title)
	fmt.Printf("Book 2 author:%s\n", Book2.author)
	fmt.Printf("Book 2 subject:%s\n", Book2.subject)
	fmt.Printf("Book 2 bookId:%d\n", Book2.bookId)*/

	/*var Book1 Books
	var Book2 Books
	// Book1描述
	Book1.title = "Go语言"
	Book1.author = "www.runoob.com"
	Book1.subject = "Go语言教程"
	Book1.bookId = 123456
	// Book2描述
	Book2.title = "Python语言"
	Book2.author = "www.runoob.com"
	Book2.subject = "Python语言教程"
	Book2.bookId = 654321
	// 打印Book1信息
	printBook(Book1)
	// 打印Book2信息
	printBook(Book2)*/

	var Book1 Books
	var Book2 Books
	// Book1描述
	Book1.title = "Go语言"
	Book1.author = "www.runoob.com"
	Book1.subject = "Go语言教程"
	Book1.bookId = 123456
	// Book2描述
	Book2.title = "Python语言"
	Book2.author = "www.runoob.com"
	Book2.subject = "Python语言教程"
	Book2.bookId = 654321
	// 打印Book1信息
	printBook2(&Book1)
	// 打印Book2信息
	printBook2(&Book2)
}
